﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using StockModel;

namespace StockAnalyst2.Converters
{
	public class StatusToColorConverter : IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value != null && Enum.IsDefined(typeof(StockModel.QuoteType), value))
			{
				switch ((QuoteType)Enum.Parse(typeof(StockModel.QuoteType), value.ToString()))
				{
					case QuoteType.Closed:
						return new SolidColorBrush(Color.FromRgb(50, 15, 15));
					case QuoteType.ClosingBid:
						return new SolidColorBrush(Color.FromRgb(40, 20, 20));
					case QuoteType.Open:
						return new SolidColorBrush(Color.FromRgb(20, 40, 20));
					case QuoteType.OpeningBid:
						return new SolidColorBrush(Color.FromRgb(40, 40, 20));
					default:
						return new SolidColorBrush(Color.FromRgb(0xff, 0, 0));
				}
			}
			else
			{
				return new SolidColorBrush(Color.FromArgb(0, 0, 0, 0));
			}
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			throw new NotImplementedException();
		}
	}
}


